<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <meta content="ie=edge" http-equiv="X-UA-Compatible">
    <title>Document</title>
    <script src="./vue.global.js"></script>
    <link href="./index.css" rel="stylesheet"/>
    <link href="./table.css" rel="stylesheet"/>
    <link href="./pugong.css" rel="stylesheet"/>
    <script src="./index.full.js"></script>

    <script>
        //适配代码
        (function (doc, win) {
            var docEI = doc.documentElement,
                resizeEvt = 'orientationchange' in window ? 'orientataionchange' : 'resize',
                recalc = function () {
                    var clientWidth = docEI.clientWidth;
                    if (!clientWidth) return;
                    //100是字体大小，1536是开发时浏览器窗口的宽度，等比计算
                    docEI.style.fontSize = 100 * (clientWidth / 1536) + 'px';
                }

            if (!doc.addEventListener) return;
            win.addEventListener(resizeEvt, recalc, false);
            doc.addEventListener('DOMContentLoaded', recalc, false);
        })(document, window);
    </script>
    <style>
        * {
            /* margin: 0;
    padding: 0; */
            font-size: 0.25rem;
        }

        .top-content {
            text-align: center;
        }

        .top-img {
            display: block;
            width: 1.5rem;
            margin: auto;
        }

        .top-title {
            font-size: 0.3rem;
            word-spacing: 10px;
            margin: 0.6rem 0;
        }

        .top-text {
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .top-input {
            width: 200px;
        }

        .top-input .el-input__wrapper {
            box-shadow: none;
            border-bottom: 1px solid #333;
            border-radius: 0;
            text-align: center;
        }

        .top-input .el-input__inner {
            text-align: center;
        }

        .top-text span {
            display: inline-block;
            font-size: 0.22rem;
            width: 1rem;
            text-align: justify;
            text-align-last: justify;
        }

        .top-company {
            font-size: 0.2rem;
            word-spacing: 10px;
        }

        .red-text {
            color: red;
        }

        .el-input.is-disabled .el-input__wrapper {
            box-shadow: none;
            background-color: transparent;
        }

        .el-input.is-disabled .el-input__inner {
            color: #000;
            -webkit-text-fill-color: #000;
        }

        .el-radio__label {
            font-size: 0.25rem;
        }

        .test-center {
            display: flex;
            align-items: center;
        }
    </style>
</head>

<body>
<div id="app">
    <div class="container">

        <div class="anchorPointMenu">
            <el-menu @select="handleMenuSelect">
                <el-menu-item index="iframe-people">
                    <span v-bind:class="{'red-text': !isFillAll('peopleForm') }">人员信息卡</span>
                </el-menu-item>
                <el-menu-item index="iframe-contract">
                    <span v-bind:class="{'red-text': !isFillAll('contractForm') }">劳动合同书</span>
                </el-menu-item>
                <el-menu-item index="iframe-physical">
                    <span v-bind:class="{'red-text': !isFillAll('physicalForm') }">劳务人员体检报告</span>
                </el-menu-item>
                <el-menu-item index="iframe-approach">
                    <span v-bind:class="{'red-text': !isFillAll('approachForm') }">劳务人员进场须知</span>
                </el-menu-item>
                <el-menu-item index="iframe-admission" :disabled="!isFillAll('approachForm')">
                    <span v-bind:class="{'red-text': !isFillAll('admissionForm') }">劳务人员入场承诺书</span>
                </el-menu-item>
                <el-menu-item index="iframe-card">
                    <span v-bind:class="{'red-text': !isFillAll('cardForm') }">本人持卡承诺书</span>
                </el-menu-item>
                <el-menu-item index="iframe-train" :disabled="!isFillAll('admissionForm')">
                    <span v-bind:class="{'red-text': !isFillAll('trainForm') }">安全教育培训</span>
                </el-menu-item>
                <el-menu-item index="iframe-disclosure" :disabled="!isFillAll('trainForm') ||
                !isFillAll('noticeForm') || !isFillAll('dangerForm') || !isFillAll('entryEduForm') ||
                !isFillAll('threeEduForm') || !isFillAll('companyEduForm') || !isFillAll('projectEduForm') ||
                !isFillAll('teamEduForm') || !isFillAll('liveForm') || !isFillAll('disciplineForm') ||
                !isFillAll('dutyForm') || !isFillAll('conDangerForm') || !isFillAll('conPunishForm')
                ">
                    <span v-bind:class="{'red-text': !isFillAll('disclosureForm') }">安全技术交底</span>
                </el-menu-item>
                <el-menu-item index="iframe-attendance">
                    <span v-bind:class="{'red-text': !isFillAll('attendanceForm') }">劳务人员考勤表</span>
                </el-menu-item>
                <el-menu-item index="iframe-salary">
                    <span v-bind:class="{'red-text': !isFillAll('salaryForm') }">劳务人员工资表</span>
                </el-menu-item>
                <el-menu-item index="iframe-settle">
                    <span v-bind:class="{'red-text': !isFillAll('settleForm') }">工资结清承诺书</span>
                </el-menu-item>
                <el-menu-item index="iframe-exit">
                    <span v-bind:class="{'red-text': !isFillAll('exitForm') }">劳务人员退场确认表</span>
                </el-menu-item>
            </el-menu>

            
            <div style="padding-left: 80px;margin-top: 15px;">
                <el-button :disabled="!isFillAll('all') || !checkTest || !checkTestName || isBtnDisable" type="primary" @click="onsubmit()">
                提交
                </el-button>
                <!-- <el-button @click="onsubmit()"  type="primary">
                    提交
                </el-button> -->
            </div>
        </div>


        <div class="contentWord ">
            <iframe border="0" frameborder="no" height="1500px" id="iframe-approach" marginheight="0"
            marginwidth="0" scrolling="no" src="./劳务人员进场须知.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1000px" id="iframe-admission" marginheight="0"
            marginwidth="0" scrolling="no" src="./劳务人员入场承诺书.html" width="100%"></iframe>
             <!-- <iframe border="0" frameborder="no" height="1850px" id="iframe-approach" marginheight="0"
            marginwidth="0" scrolling="no" src="./农民工进场须知.html" width="100%"></iframe>
             <iframe border="0" frameborder="no" height="900px" id="iframe-admission" marginheight="0"
            marginwidth="0" scrolling="no" src="./农民工入场承诺书.html" width="100%"></iframe> -->
            <iframe border="0" frameborder="no" height="1200px" id="iframe-card" marginheight="0"
            marginwidth="0" scrolling="no" src="./本人持卡承诺书.html" width="100%" v-show="false"></iframe>
            <iframe border="0" frameborder="no" height="1300px" id="iframe-train" marginheight="0"
            marginwidth="0" scrolling="no" src="./封面.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="500px"  marginheight="0"
            marginwidth="0" scrolling="no" src="./填表说明.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1100px" marginheight="0"
            marginwidth="0" scrolling="no" src="./致工人朋友一封信.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1300px" id="iframe-notice"  marginheight="0"
            marginwidth="0" scrolling="no" src="./进场须知.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1400px" id="iframe-danger"  marginheight="0"
            marginwidth="0" scrolling="no" src="./职业危害告知书.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="500px"  id="iframe-entryEdu"  marginheight="0"
            marginwidth="0" scrolling="no" src="./入场安全教育记录.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1800px" id="iframe-threeEdu"  marginheight="0"
            marginwidth="0" scrolling="no" src="./三级教育卡.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1500px" id="iframe-companyEdu"  marginheight="0"
            marginwidth="0" scrolling="no" src="./公司级安全教育记录.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1500px" id="iframe-projectEdu"  marginheight="0"
            marginwidth="0" scrolling="no" src="./项目级安全教育记录.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1650px" id="iframe-teamEdu"  marginheight="0"
            marginwidth="0" scrolling="no" src="./班组级安全教育记录.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1300px" id="iframe-live"  marginheight="0"
            marginwidth="0" scrolling="no" src="./生活区管理制度.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1350px" id="iframe-discipline"  marginheight="0"
            marginwidth="0" scrolling="no" src="./安全纪律承诺书.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1700px" id="iframe-duty"  marginheight="0"
            marginwidth="0" scrolling="no" src="./安全生产责任书.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="2200px" id="iframe-conDanger"  marginheight="0"
            marginwidth="0" scrolling="no" src="./施工现场安全管理及危险告知书.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="2150px" id="iframe-conPunish"  marginheight="0"
            marginwidth="0" scrolling="no" src="./施工现场安全管理处罚标准.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1800px"  marginheight="0"
            marginwidth="0" scrolling="no" src="./安全防护用品使用图解.html" width="100%"></iframe>
            <!-- <iframe border="0" frameborder="no" height="1700px"  marginheight="0"
            marginwidth="0" scrolling="no" src="./作业人员岗前安全教育培训试卷.html" width="100%"></iframe>
             <iframe border="0" frameborder="no" height="1700px"  marginheight="0"
            marginwidth="0" scrolling="no" src="./消防安全培训试题.html" width="100%"></iframe>
            <iframe border="0" frameborder="no" height="1700px"  marginheight="0"
            marginwidth="0" scrolling="no" src="./职业健康培训试题.html" width="100%"></iframe> -->
            
            <!--试题-->
            <div class="table-content" style="text-align: left;font-size: 0.25rem;" v-for="(questionItem,questionIndex) in questionsList" :index="questionIndex">
                <h3 style="font-size: 0.25rem;text-align: center;">{{questionItem.title}}</h3>

                <div class="test-top">
                    <div class="test-top-item test-center">
                        <span @click="setUpEquipment2(questionIndex,'TaskSignFinger')">姓名: </span>
                        <el-image
                            v-if="questionsList[questionIndex].mySign"
                            class="sign_img"
                            :src="questionsList[questionIndex].mySign"
                            fit="fill"
                        ></el-image>
                        <el-input class="promise-input" v-else></el-input>
                        <!-- <el-input class="promise-input" v-model="questionsList[questionIndex].name"></el-input> -->
                    </div>
                    <div class="test-top-item test-center">
                        <span>得分：</span>
                        <el-input class="promise-input"></el-input>
                    </div>
                </div>
                <div class="test-one">

                    <h3>{{questionItem.trainBankChildResDTO.radioTitle}}</h3>
                    <div :key="index" class="question" v-for="(item,index) in questionItem.trainBankChildResDTO.radioList">
                        <div class="question-title">{{index + 1}}、{{item.name}}(
                            <el-input class="people-input"
                                      disabled="true"
                                      v-model="questionsList[questionIndex].trainBankChildResDTO.radioList[index].personAnswer"></el-input>
                            )
                        </div>
                        <div class="question-item1">
                            <el-radio-group v-model="questionsList[questionIndex].trainBankChildResDTO.radioList[index].personAnswer" @change="changeTest">
                                <el-radio :value="item1.value"
                                          v-for="(item1,ind) in formatAnswerContent(item.content)">{{item1.label}}
                                </el-radio>
                            </el-radio-group>
                        </div>
                    </div>

                    <h3>{{questionItem.trainBankChildResDTO.panDuanTitle}}</h3>
                    <div class="question" v-for="(item,index) in questionItem.trainBankChildResDTO.panDuanList">
                        <div class="question-title1">(
                            <el-radio-group v-model="questionsList[questionIndex].trainBankChildResDTO.panDuanList[index].personAnswer" @change="changeTest">
                                <el-radio :value="1">√</el-radio>
                                <el-radio :value="2">×</el-radio>
                            </el-radio-group>
                            ){{index + 1}}.{{item.name}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
<script>
    const {
        createApp,
        reactive,
        toRefs,
        ref,
        onMounted
    } = Vue;
    const vue3Composition = {
        setup() {
            const isFillAll = (key) => {
                let flag = true
                if (key == 'all') {
                    let mustArr = mustData.value
                    mustArr.forEach(item => {
                        item.keys.forEach(item => {
                            if (!item.isFill) flag = false
                        })
                    })
                } else {
                    let arr = mustData.value.find(item => item.form == key)
                    arr.keys.forEach(item => {
                        if (!item.isFill) flag = false
                    })
                }
                return flag
            }
            
            window.addEventListener('message', e => {
                    let data = e.data
                    let keys = mustData.value.find(item => item.form == data.form)
                    keys.keys.find(item => item.key == data.key).isFill = data.isFill
                    
                });
            //必填字段
            const mustData = ref(
                [
                {
                    // 人员信息卡
                    form: 'peopleForm',
                    keys: []
                },
                {
                    // 劳动合同书
                    form: 'contractForm',
                    keys: []
                },
                {
                    // 体检报告
                    form: 'physicalForm',
                    keys: []
                },
                {
                    // 农民工进场须知
                    form: 'approachForm',
                    keys: [
                        // {
                        //     key: 'infoSign',
                        //     isFill: false
                        // },
                        {
                            key: 'defeSign',
                            isFill: false
                        },
                    ]
                },
                {
                    // 农民工入场承诺书
                    form: 'admissionForm',
                    keys: [
                        {
                            key: 'promiseSign',
                            isFill: false
                        }
                    ]
                },
                {
                    // 本人持卡承诺书
                    form: 'cardForm',
                    keys: [
                        // {
                        //     key: 'promiseSign',
                        //     isFill: false
                        // }
                    ]
                },
                {
                    // 安全教育培训
                    form: 'trainForm',
                    keys: [
                        // {
                        //     key: 'enteyTime',
                        //     isFill: false
                        // }
                    ]
                },
                {
                    // 安全技术交底卡
                    form: 'disclosureForm',
                    keys: []
                },
                {
                    // 考勤表
                    form: 'attendanceForm',
                    keys: []
                },
                {
                    // 工资表
                    form: 'salaryForm',
                    keys: []
                },
                {
                    // 工资结清承诺书
                    form: 'settleForm',
                    keys: []
                },
                {
                    // 农民工退场确认表
                    form: 'exitForm',
                    keys: []
                },
                {
                    // 进场须知
                    form: 'noticeForm',
                    keys: [
                        {
                            key: 'acceptSign',
                            isFill: false
                        }
                    ]
                },
                {
                    // 职业危害告知书
                    form: 'dangerForm',
                    keys: [
                        {
                            key: 'acceptSign',
                            isFill: false
                        }
                    ]
                },
                {
                    // 入场安全教育记录
                    form: 'entryEduForm',
                    keys: [
                        // {
                        //     key: 'type',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'deep',
                        //     isFill: false
                        // },
                    ]
                },
                {
                    // 三级教育卡
                    form: 'threeEduForm',
                    keys: [
                        // {
                        //     key: 'cepSign',
                        //     isFill: false
                        // },
                        {
                            key: 'ceiSign',
                            isFill: false
                        },
                        // {
                        //     key: 'pepSign',
                        //     isFill: false
                        // },
                        {
                            key: 'peiSign',
                            isFill: false
                        },
                        // {
                        //     key: 'tepSign',
                        //     isFill: false
                        // },
                        {
                            key: 'teiSign',
                            isFill: false
                        },
                    ]
                },
                {
                    // 公司级安全教育记录
                    form: 'companyEduForm',
                    keys: [
                        // {
                        //     key: 'speakerSign',
                        //     isFill: false
                        // },
                        {
                            key: 'eiSign',
                            isFill: false
                        },
                        // {
                        //     key: 'syear',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'smonth',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'sday',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'eyear',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'emonth',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'eday',
                        //     isFill: false
                        // },
                    ]
                },
                {
                    // 项目级安全教育记录
                    form: 'projectEduForm',
                    keys: [
                        // {
                        //     key: 'speakerSign',
                        //     isFill: false
                        // },
                        {
                            key: 'eiSign',
                            isFill: false
                        },
                        // {
                        //     key: 'syear',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'smonth',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'sday',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'eyear',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'emonth',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'eday',
                        //     isFill: false
                        // },
                    ]
                },
                {
                    // 班组级安全教育记录
                    form: 'teamEduForm',
                    keys: [
                        // {
                        //     key: 'speakerSign',
                        //     isFill: false
                        // },
                        {
                            key: 'eiSign',
                            isFill: false
                        },
                        // {
                        //     key: 'syear',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'smonth',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'sday',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'eyear',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'emonth',
                        //     isFill: false
                        // },
                        // {
                        //     key: 'eday',
                        //     isFill: false
                        // },
                    ]
                },
                {
                    // 生活区管理制度
                    form: 'liveForm',
                    keys: [
                        {
                            key: 'mySign',
                            isFill: false
                        },
                    ]
                },
                {
                    // 安全纪律承诺书
                    form: 'disciplineForm',
                    keys: [
                        {
                            key: 'promiseSign',
                            isFill: false
                        },
                    ]
                },
                {
                    // 安全生产责任书
                    form: 'dutyForm',
                    keys: [
                        // {
                        //     key: 'projectSign',
                        //     isFill: false
                        // },
                        {
                            key: 'constructorSing',
                            isFill: false
                        },
                    ]
                },
                {
                    // 施工现场安全管理及危险告知书
                    form: 'conDangerForm',
                    keys: [
                        {
                            key: 'acceptSign',
                            isFill: false
                        },
                    ]
                },
                {
                    // 施工现场安全管理处罚标准
                    form: 'conPunishForm',
                    keys: [
                        {
                            key: 'mySign',
                            isFill: false
                        },
                    ]
                },
            ])
            const healthSign = ref(false)
            const topForm = ref({
                number: "",
                company: "",
                name: '',
                job: ""
            })
            const testForm = ref({
                name: "",
                qualify: "",
                time: "",
                title: "",
                fraction: "",
                list: [],
                examId: "",
                personCode: "",
            })
            // 校验试卷是否填完
            const checkTest = ref(false)
            // 当前试卷签名索引 没有签名的话显示99
            const testIndex = ref(99)
            // 校验试卷姓名是否都填完
            const checkTestName = ref(false)
            let dataKey = ref()

            // 人员信息
            const personList = ref({})
            // 结业证书
            const oppfCocList = ref({})
            // 试题
            const questionsList = ref([])
         
            // 农民工进场须知
            const iframeApproach = ref('')
            // 农民工入场承诺书
            const iframeAdmission = ref('')
            // 本人持卡承诺书
            const iframeCard = ref('')
            // 封面
            const iframeTrain = ref('')
            // 进场须知
            const iframeNotice = ref('')
            // 职业危害告知书
            const iframeDanger = ref('')
            // 入场安全教育记录
            const iframeEntryEdu = ref('')
            // 三级教育卡
            const iframeThreeEdu = ref('')
            // 公司级安全教育记录
            const iframeCompanyEdu = ref('')
            // 项目级安全教育记录
            const iframeProjectEdu = ref('')
            // 班组级安全教育记录
            const iframeTeamEdu = ref('')
            // 生活区管理制度
            const iframeLive = ref('')
            // 安全纪律承诺书
            const iframeDiscipline = ref('')
            // 安全生产责任书
            const iframeDuty = ref('')
            // 施工现场安全管理及危险告知书
            const iframeConDanger = ref('')
            // 施工现场安全管理处罚标准
            const iframeConPunish = ref('')

            const isBtnDisable = ref(false)

            window.childListener = function (data) {
                setUpEquipment(data.key, data.type)
            }

            // 使用Date对象进行日期计算
            const addDays = (year, month, day, add) => {
                let newDate = new Date(year, Number(String(month).replace(/^0+/, '')) - 1, Number(String(day).replace(
                    /^0+/, '')) + add);
                return newDate.toLocaleDateString().split('/');
            }
            window.handleMessage = (event) => {
                let eventData = JSON.parse(event.data)
                console.log("这里是父项目传来的值", eventData);
                // return;
                if (eventData.type == 1) {
                    let data = eventData.data
                    // console.log(data.userAnswerVo, "datadatadata")

                    personList.value = {
                        name: data.laborPersonnel.name,
                        sexName: data.laborPersonnel.sexName,
                        idCard: data.laborPersonnel?.idCard || '',
                        cardTime: data.laborPersonnel.idCardTime,
                        phone: data.laborPersonnel.phone,
                        laborName: data.laborPersonnel.laborName,
                        workTypeName: data.laborPersonnel.workTypeName,
                        degreeEducationName: data.laborPersonnel?.degreeEducationName || '',
                        enteyTime: data.laborPersonnel?.enteyTime || '',
                        age: data.laborPersonnel.age.toString(),
                    }
                    console.log(personList.value, "personList")
                    // 试题 每个试题加上选项
                    questionsList.value = data.userAnswerVo
                    questionsList.value.forEach(item => {
                        item.trainBankChildResDTO.panDuanList.forEach(item1 => {
                            item1.personAnswer = ''
                        })
                        item.trainBankChildResDTO.radioList.forEach(item2 => {
                            item2.personAnswer = ''
                        })
                        item.mySign = ''
                    })

                    oppfCocList.value = data.oppfCoc

                    setTimeout(() => {
                        iframeApproach.value = document.getElementById("iframe-approach");
                        iframeAdmission.value = document.getElementById("iframe-admission");
                        iframeCard.value = document.getElementById("iframe-card");
                        iframeTrain.value = document.getElementById("iframe-train");
                        iframeNotice.value = document.getElementById("iframe-notice");
                        iframeDanger.value = document.getElementById("iframe-danger");
                        iframeEntryEdu.value = document.getElementById("iframe-entryEdu");
                        iframeThreeEdu.value = document.getElementById("iframe-threeEdu");
                        iframeCompanyEdu.value = document.getElementById("iframe-companyEdu");
                        iframeProjectEdu.value = document.getElementById("iframe-projectEdu");
                        iframeTeamEdu.value = document.getElementById("iframe-teamEdu");
                        iframeLive.value = document.getElementById("iframe-live");
                        iframeDiscipline.value = document.getElementById("iframe-discipline");
                        iframeDuty.value = document.getElementById("iframe-duty");
                        iframeConDanger.value = document.getElementById("iframe-conDanger");
                        iframeConPunish.value = document.getElementById("iframe-conPunish");
                        //设置默认值
                        iframeApproach.value.contentWindow.setData(data.laborPersonnel)
                        iframeAdmission.value.contentWindow.setData(data.laborPersonnel)
                        iframeCard.value.contentWindow.setData(data.laborPersonnel)
                        iframeTrain.value.contentWindow.setData(data.laborPersonnel)
                        iframeEntryEdu.value.contentWindow.setData(data.laborPersonnel)
                        iframeThreeEdu.value.contentWindow.setData(data.laborPersonnel)
                        iframeDuty.value.contentWindow.setData(data.laborPersonnel)
                        iframeCompanyEdu.value.contentWindow.setData(data.laborPersonnel)
                        iframeProjectEdu.value.contentWindow.setData(data.laborPersonnel)
                        iframeTeamEdu.value.contentWindow.setData(data.laborPersonnel)
                    }, 3000);


                } else {
                    if(testIndex.value != 99) {
                        questionsList.value[testIndex.value].mySign = 'data:image/png;base64,' + eventData.data + ''
                        checkTestName.value = questionsList.value.every(item => item.mySign != '')
                        testIndex.value = 99
                        console.log(testIndex.value,checkTestName.value)
                    }else {
                        let dataKeyArr = dataKey.value.split('.')
                    console.log(dataKeyArr, 'dataKeyArr')
                    let iframeDate = ''

                    if(dataKeyArr[0] == 'approachForm') {
                        iframeDate = iframeApproach.value
                    }else if(dataKeyArr[0] == 'admissionForm') {
                        iframeDate = iframeAdmission.value
                    }else if(dataKeyArr[0] == 'cardForm') {
                        iframeDate = iframeCard.value
                    }else if(dataKeyArr[0] == 'noticeForm') {
                        iframeDate = iframeNotice.value
                    }else if(dataKeyArr[0] == 'dangerForm') {
                        iframeDate = iframeDanger.value
                    }else if(dataKeyArr[0] == 'threeEduForm') {
                        iframeDate = iframeThreeEdu.value
                    }else if(dataKeyArr[0] == 'companyEduForm') {
                        iframeDate = iframeCompanyEdu.value
                    }else if(dataKeyArr[0] == 'projectEduForm') {
                        iframeDate = iframeProjectEdu.value
                    }else if(dataKeyArr[0] == 'teamEduForm') {
                        iframeDate = iframeTeamEdu.value
                    }else if(dataKeyArr[0] == 'liveForm') {
                        iframeDate = iframeLive.value
                    }else if(dataKeyArr[0] == 'disciplineForm') {
                        iframeDate = iframeDiscipline.value
                    }else if(dataKeyArr[0] == 'dutyForm') {
                        iframeDate = iframeDuty.value
                    }else if(dataKeyArr[0] == 'conDangerForm') {
                        iframeDate = iframeConDanger.value
                    }else if(dataKeyArr[0] == 'conPunishForm') {
                        iframeDate = iframeConPunish.value
                    }

                    if (iframeDate) {
                        let mustArr = mustData.value.find(item => item.form == dataKeyArr[0])
                        mustArr.keys.forEach(item => {
                            if (item.key == dataKeyArr[1]) item.isFill = true
                        })
                        iframeDate.contentWindow.setSign({
                            img: 'data:image/png;base64,' + eventData.data + '',
                            key: dataKeyArr[1]
                        })
                    }
                    }
                }

            };
            function handleMenuSelect(index) {
                const anchor = document.getElementById(index);
                if (anchor) {
                    anchor.scrollIntoView({
                        behavior: 'smooth'
                    });
                }
            }

            window.sure = () => {
                isBtnDisable.value = false
            }

            const changeTest = () => {
                checkTest.value = questionsList.value.every(exam => {
                    const { radioList, panDuanList } = exam.trainBankChildResDTO;
        
                    // 检查单选题是否全部作答
                    const radioAllAnswered = radioList.every(question => 
                        question.personAnswer != "" && question.personAnswer != undefined
                    );
                    
                    // 检查判断题是否全部作答
                    const panDuanAllAnswered = panDuanList.every(question => 
                        question.personAnswer != "" && question.personAnswer != undefined
                    );
                    
                    return radioAllAnswered && panDuanAllAnswered;
                });
            }

            const formatAnswerContent = (data) => {
                const alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
                const dataArr = JSON.parse(data)
                if (dataArr && dataArr.length) {
                    return dataArr.map((item, index) => ({
                        label: alphabet[index] + '、' + item,
                        value: alphabet[index]
                    }))
                } else {
                    return []
                }
            }

            //peopleForm.sign
            const setUpEquipment = (key, type) => {
                console.log(key,'===setUpEquipment==key',type)
                dataKey.value = key
                //提交这么写
                // window.parent.postMessage(type, "*");
                // window.parent.postMessage("hello，我即将传给父项目", "*");
                window.parent.childListener({
                    data: type
                });
            }
            // 试题姓名签字按指纹
            const setUpEquipment2 = (index, type) => {
                testIndex.value = index
                console.log(index,'===setUpEquipment2==key',type)
                window.parent.childListener({
                    data: type
                });
            }

            const onsubmit = () => {

                isBtnDisable.value = true

                personList.value.cardTime = iframeThreeEdu.value.contentWindow.getData().cardTime
                personList.value.enteyTime = iframeTrain.value.contentWindow.getData().enteyTime

                // 建卡时间  当天-6
                const today = new Date();
                // 复制日期对象以避免修改原始日期
                const pastDate = new Date(today);
                // 减去6天
                pastDate.setDate(today.getDate() - 6);
                const year = String(pastDate.getFullYear());
                const month = String(pastDate.getMonth() + 1).padStart(2, "0"); // 月份从0开始，需+1并补零
                const day = String(pastDate.getDate()).padStart(2, "0"); // 日期补零
                oppfCocList.value.year = year
                oppfCocList.value.month = month
                oppfCocList.value.day = day

                // console.log(personList.value, 'personList.value')
                // console.log(iframeApproach.value.contentWindow.getData(), '农民工进场须知');
                // console.log(iframeAdmission.value.contentWindow.getData(), '农民工入场承诺书');
                // console.log(iframeCard.value.contentWindow.getData(), '本人持卡承诺书');
                // console.log(iframeTrain.value.contentWindow.getData(), '封面');
                // console.log(iframeNotice.value.contentWindow.getData(), '进场须知');
                // console.log(iframeDanger.value.contentWindow.getData(), '职业危害告知书');
                // console.log(iframeEntryEdu.value.contentWindow.getData(), '入场安全教育记录');
                // console.log(iframeThreeEdu.value.contentWindow.getData(), '三级教育卡');
                // console.log(iframeCompanyEdu.value.contentWindow.getData(), '公司级安全教育记录');
                // console.log(iframeProjectEdu.value.contentWindow.getData(), '项目级安全教育记录');
                // console.log(iframeTeamEdu.value.contentWindow.getData(), '班组级安全教育记录');
                // console.log(iframeLive.value.contentWindow.getData(), '生活区管理制度');
                // console.log(iframeDiscipline.value.contentWindow.getData(), '安全纪律承诺书');
                // console.log(iframeDuty.value.contentWindow.getData(), '安全生产责任书');
                // console.log(iframeConDanger.value.contentWindow.getData(), '施工现场安全管理及危险告知书');
                // console.log(iframeConPunish.value.contentWindow.getData(), '施工现场安全管理处罚标准');
                // console.log(questionsList.value, '试题');
                // console.log(oppfCocList.value,'结业证书')
                // return;

                let dataJson = {
                    laborPersonnel: personList.value,
                    oppfApproach: iframeApproach.value.contentWindow.getData(),
                    oppfePromise: iframeAdmission.value.contentWindow.getData(),
                    oppfPromise: iframeCard.value.contentWindow.getData(),
                    oppfeNotice: iframeNotice.value.contentWindow.getData(),
                    oppfHealth: iframeDanger.value.contentWindow.getData(),
                    oppfSec: iframeThreeEdu.value.contentWindow.getData(),
                    oppfClser: iframeCompanyEdu.value.contentWindow.getData(),
                    oppfPlser: iframeProjectEdu.value.contentWindow.getData(),
                    oppfTlser: iframeTeamEdu.value.contentWindow.getData(),
                    oppfMsfla: iframeLive.value.contentWindow.getData(),
                    oppfSdcl: iframeDiscipline.value.contentWindow.getData(),
                    oppfSpra: iframeDuty.value.contentWindow.getData(),
                    oppfCssmahn: iframeConDanger.value.contentWindow.getData(),
                    oppfPsfsmacs: iframeConPunish.value.contentWindow.getData(),
                    userAnswerVo: questionsList.value,
                    oppfCoc: oppfCocList.value,
                }
                let data = {
                    type: "form-d",
                    personCard: personList.value.idCard,
                    dataJson
                }

                window.parent.childListener({
                    data: JSON.stringify(data)
                });

            }


            return {
                topForm,
                testForm,
                setUpEquipment,
                handleMenuSelect,
                formatAnswerContent,
                onsubmit,
                isFillAll,
                questionsList,
                personList,
                changeTest,
                checkTest,
                setUpEquipment2,
                testIndex,
                checkTestName,
                isBtnDisable
            }
        }

    }
    const app = createApp(vue3Composition).use(ElementPlus).mount('#app');
</script>
</body>


</html>